home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Data 2002 May / CD Rom Data Mayıs 2002.iso / Freeware / Blitz Basic / data1.cab / Support / help / samples / aristoids / aristoids.bb next >
Encoding:
Text File  |  2002-04-10  |  31.4 KB  |  1,247 lines

  1. ; aristoids
  2. ; by aristides mytaras
  3. ; TURN DEBUG OFF or you will get a lousy frame rate
  4.  
  5. AppTitle "aristoids"    
  6. Global width=1024,height=768,depth=16        
  7. Graphics width,height;,depth        
  8. SetBuffer BackBuffer()    
  9. SeedRnd MilliSecs()
  10.  
  11. Global chnEngine, chnbuzz
  12.  
  13. Global smallfont,bigfont,hugefont,music
  14. Global fire_sound=LoadSound( "machineg.wav" )
  15. Global buzz_sound=LoadSound( "blast4_.wav" )
  16. Global smexp_sound=LoadSound( "blast4_.wav" )
  17. Global lowsmexp_sound=LoadSound( "blast4_.wav" )
  18. Global exp_sound=LoadSound( "explode4.wav" ):SoundVolume exp_sound,0.95
  19. Global engine_sound=LoadSound( "engn002_.wav" )
  20. Global click_sound=LoadSound("clicktwo.wav")
  21. Global powerup_sound=LoadSound( "flaskgone.wav" ):SoundVolume powerup_sound,0.85
  22. SoundPitch buzz_sound,4000:LoopSound buzz_sound:chnbuzz=PlaySound(buzz_sound):PauseChannel chnbuzz
  23. LoopSound engine_sound:chnEngine=PlaySound(engine_Sound):PauseChannel chnEngine:SoundVolume engine_sound,0.93
  24. SoundPitch lowsmexp_sound,10000
  25. Global level,bulletdistance,bulletnumber,bulletsfire,bulletshit,bulletspeed,enemybulletspeed,hiscore
  26. Global poweruptimer,pupx,pupy,pupcount,puptype,pupprobability,puptext$,gameovercounter,clearlevelcounter
  27. Global targetscorefornextlife,alienswelcome,alienswelcomecounter
  28. Global x#,y#,xvel#,yvel#,an#,bulletsfired,audioseperation,controltype
  29. Global joystick=JoyType()
  30. Global yourname$ ;bug with string-return?
  31. audioseperation=0.85:controltype=0 ;asteroids movement
  32.  
  33.  
  34. smallfont=LoadFont( "Arial",18,True,False,False )
  35. bigfont=LoadFont( "Arial",26,True,False,False )
  36. hugefont=LoadFont( "Arial",65,True,False,False )
  37. SetFont smallfont
  38.  
  39.  
  40. Dim hiscores(11)
  41. Dim hinames$(11)
  42. Dim hidates$(11)
  43. Dim levelreached(11)
  44. Dim control(11)
  45.  
  46. Type playership                            
  47.     Field x#,y#,xvel#,yvel#                    
  48.     Field an#,anvel#,antarg#
  49.     Field Lastx#,Lasty#                            
  50.     Field speed#
  51.     Field bulletsfired,shield,autoshield,shieldflag
  52.     Field score,life,lives
  53. End Type
  54.  
  55. Type enemy
  56.     Field x#,y#,xvel#,yvel#    
  57.     Field targx,targy,targcount
  58.     Field shooter
  59.     Field life
  60.     Field agression,aim
  61.     Field g
  62. End Type
  63.  
  64. Type asteroid
  65.     Field x#,y#,xvel#,yvel#    
  66.     Field an,speed#
  67.     Field life
  68.     Field size
  69.     Field r,g,b
  70. End Type
  71.  
  72. Type bullet
  73.     Field x#,y#,xvel#,yvel#
  74.     Field life
  75.     Field fromwho
  76. End Type
  77.  
  78. Type Frag
  79.     ;particles
  80.     Field x#,y#,xs#,ys#
  81.     Field r,g,b
  82. End Type
  83.  
  84. Global p1.playership=New playership        ; Create player's ship
  85.  
  86. titlescreen()
  87.  
  88. ;-------------------------------------------------------------------------
  89. ; Main loop:
  90. While Not KeyDown(1)                        ; Do until ESC is pressed
  91.     Cls                                        ; Clear the screen.
  92.     
  93.     debug=0
  94.     If debug<>0 And KeyDown(2)
  95.     For p.asteroid=Each asteroid
  96.     Delete p
  97.     Next
  98.     
  99.     For g.enemy=Each enemy
  100.     Delete g
  101.     Next
  102.     
  103.     For h.bullet=Each bullet
  104.     Delete h
  105.     Next
  106.     EndIf
  107.     
  108.     If KeyDown(25)=1
  109.         ; pause function
  110.         Repeat
  111.         Until KeyDown(25)=0
  112.         Repeat:Until KeyDown(25)=1 Or KeyDown(29)=1 Or KeyDown(57)=1
  113.         Repeat:Until KeyDown(25)=0 Or KeyDown(29)=0 Or KeyDown(57)=0
  114.     EndIf
  115.     
  116.     If gameovercounter<=0
  117.         ; main player input
  118.         If controltype=0
  119.         ;=======   control type 1: asteroids
  120.         ;-------------------------------------
  121.         If KeyDown(200) Or KeyDown(56) Or KeyDown(44) Or (joystick<>0 And JoyYDir())
  122.             p1\speed=p1\speed+0.002
  123.             enginepitch=enginepitch+1000
  124.         Else
  125.             enginepitch=enginepitch-600
  126.         EndIf
  127.         enginepitch=enginepitch*0.95
  128.         If enginepitch>70 Then
  129.             ;revs
  130.             ResumeChannel chnEngine
  131.             SoundPitch engine_sound,enginepitch
  132.         Else
  133.             PauseChannel chnEngine
  134.         EndIf
  135.         
  136.         If KeyDown(203) Or KeyDown(75) Or KeyDown(51) Or (joystick<>0 And JoyXDir()=-1)Then p1\an=p1\an-3    
  137.         If KeyDown(205) Or KeyDown(77) Or KeyDown(52) Or(joystick<>0 And JoyXDir()=1)Then p1\an=p1\an+3
  138.         If bulfired=0 And (KeyDown(57) Or KeyDown(29) Or (joystick<>0 And JoyDown(1))) And clearlevelcounter<=0 Then firebullet(250,bulletspeed):bulfired=bulletdistance
  139.         If bulfired>0 Then bulfired=bulfired-1
  140.         If KeyDown(208) Or KeyDown(42) Or (joystick<>0 And JoyDown(2)) Then
  141.             If p1\shield>1 Then p1\shieldflag=1:p1\shield=p1\shield-1
  142.         Else
  143.             p1\shieldflag=0
  144.         EndIf
  145.         EndIf
  146.         If controltype>=1
  147.         ;=======   control type 2: beginner
  148.         ;-----------------------------------
  149.         revup=0
  150.         If controltype=1 Then revver=1
  151.         If controltype=2 Then revver=3
  152.         If KeyDown(200) Or KeyDown(72)  Or (joystick<>0 And JoyYDir())
  153.             ;up
  154.             revup=revver
  155.             p1\antarg=270
  156.         EndIf
  157.         If KeyDown(203) Or KeyDown(75) Or (joystick<>0 And JoyXDir()=-1)
  158.             ;left
  159.             revup=revver
  160.             p1\antarg=180
  161.         EndIf
  162.         If KeyDown(205) Or KeyDown(77) Or(joystick<>0 And JoyXDir())
  163.             ;Right
  164.             revup=revver
  165.             p1\antarg=0
  166.         EndIf
  167.         If KeyDown(208) Or KeyDown(80) Or (joystick<>0 And JoyYDir()=-1)
  168.             ;down
  169.             revup=revver
  170.             p1\antarg=90
  171.         EndIf
  172.     
  173.         ;diagonals
  174.         If (KeyDown(200) Or KeyDown(72) Or (joystick<>0 And JoyYDir())) And (KeyDown(205) Or KeyDown(77) Or(joystick<>0 And JoyXDir()))
  175.             ;up+right
  176.             revup=revver
  177.             p1\antarg=315
  178.         EndIf
  179.         If (KeyDown(200) Or KeyDown(72) Or (joystick<>0 And JoyYDir())) And (KeyDown(203) Or KeyDown(75) Or (joystick<>0 And JoyXDir()=-1))
  180.             ;up+left
  181.             revup=revver
  182.             p1\antarg=225
  183.         EndIf
  184.         If (KeyDown(208) Or KeyDown(80) Or (joystick<>0 And JoyYDir()=-1)) And (KeyDown(205) Or KeyDown(77) Or(joystick<>0 And JoyXDir()))
  185.             ;down+Right
  186.             revup=revver
  187.             p1\antarg=45
  188.         EndIf
  189.         If (KeyDown(208) Or KeyDown(80) Or (joystick<>0 And JoyYDir()=-1)) And (KeyDown(203) Or KeyDown(75) Or (joystick<>0 And JoyXDir()=-1))
  190.             ;down+left
  191.             revup=revver
  192.             p1\antarg=135
  193.         EndIf    
  194.         
  195.         ;thrust
  196.         If KeyDown(56) Then revup=2:If revver=1 Then p1\speed=p1\speed+0.00065
  197.         
  198.         Lastan=p1\an
  199.         If p1\an<>p1\antarg And (revup=1 Or revup=3)
  200.         dif1=p1\antarg-p1\an
  201.         dif2=p1\an-p1\antarg
  202.         If p1\antarg=0 And p1\an>180 Then p1\an=p1\an+6
  203.         If p1\antarg=270 And p1\an<90 Then p1\an=p1\an-6
  204.         If p1\antarg=90 And (p1\an>270) Then p1\an=p1\an+6
  205.         If p1\antarg=45 And (p1\an>225) Then p1\an=p1\an+6
  206.         If p1\antarg=135 And (p1\an>315) Then p1\an=p1\an+6
  207.         If p1\antarg=315 And (p1\an<135) Then p1\an=p1\an-6
  208.         If dif1>dif2 Then 
  209.             p1\an=p1\an+3
  210.         Else
  211.             p1\an=p1\an-3
  212.         EndIf
  213.         EndIf
  214.             
  215.         If revup=>1
  216.             If revup<>3 Then
  217.                 p1\speed=p1\speed+0.002
  218.                 If revver=1 Then p1\speed=p1\speed-0.00135
  219.                 enginepitch=enginepitch+1000:revup=0
  220.             EndIf
  221.         Else
  222.             enginepitch=enginepitch-600
  223.             p1\an=Lastan
  224.         EndIf                    
  225.             
  226.         enginepitch=enginepitch*0.95
  227.         If enginepitch>70 Then
  228.             ;revs
  229.             ResumeChannel chnEngine
  230.             SoundPitch engine_sound,enginepitch
  231.         Else
  232.             PauseChannel chnEngine
  233.         EndIf
  234.         
  235.         
  236.         ;If KeyDown(203) Or KeyDown(75) Or (joystick<>0 And JoyXDir()=-1)Then p1\an=p1\an-3    
  237.         ;If KeyDown(205) Or KeyDown(77) Or(joystick<>0 And JoyXDir()=1)Then p1\an=p1\an+3
  238.     
  239.         
  240.         If bulfired=0 And (KeyDown(57) Or KeyDown(29) Or (joystick<>0 And JoyDown(1))) And clearlevelcounter<=0 Then firebullet(250,bulletspeed):bulfired=bulletdistance
  241.         If bulfired>0 Then bulfired=bulfired-1
  242.         If KeyDown(42) Or (joystick<>0 And JoyDown(2)) Then
  243.             If p1\shield>1 Then p1\shieldflag=1:p1\shield=p1\shield-1
  244.         Else
  245.             p1\shieldflag=0
  246.         EndIf
  247.         EndIf
  248.     Else
  249.         gameovercounter=gameovercounter-1
  250.         PauseChannel chnEngine
  251.         
  252.         If gameovercounter=0 Then
  253.             If checkhighscore("aristoidsprefs",p1\score)<11
  254.                 ;highscore achieved
  255.                 PlaySound powerup_sound
  256.                 ;WaitKey
  257.                 entername("",p1\score)
  258.                 sorthighscores("aristoidsprefs",yourname$,p1\score,level)
  259.                 savehighscores("aristoidsprefs")
  260.             EndIf
  261.             titlescreen()
  262.         EndIf
  263.     EndIf
  264.     If p1\autoshield>0 Then p1\autoshield=p1\autoshield-1:p1\shieldflag=2
  265.     
  266.     UpdateShip()
  267.     updatebullets()
  268.     UpdateExplosion()
  269.     enemyships=UpdateEnemy()
  270.     asters=UpdateAsteroid(0)
  271.     
  272.     If poweruptimer<=0 And pupcount<=0 And Rnd(0,pupprobability)<=1 And p1\score>500
  273.         ;generate powerup
  274.         pupx=Rnd(width-40)+20
  275.         pupy=Rnd(height-40)+20
  276.         poweruptimer=800
  277.         pupdecide=Rnd(1,100)
  278.         If pupdecide>85 Then puptype=1:puptext="maniac's machinegun"
  279.         If pupdecide<30 Then puptype=2:puptext="sniper"
  280.         If pupdecide>=30 And pupdecide<=60 Then puptype=3:puptext="machinegun"    
  281.         If pupdecide>60 And pupdecide<=70 Then puptype=4:puptext="1000 points"
  282.         If pupdecide>70 And pupdecide<=78 Then puptype=5:puptext="full shield"
  283.         If pupdecide>78 And pupdecide<=85 Then puptype=6:puptext="full energy"    
  284.     EndIf
  285.     
  286.     If pupcount>0 Then
  287.         ;pupcount=pupcount-1
  288.     Else
  289.         bulletdistance=20 ;distance between the bullets
  290.         bulletnumber=10    ;number of bullets allowed on screen
  291.         bulletspeed=3    
  292.     EndIf
  293.     
  294.     If poweruptimer>0
  295.         Color 50,(poweruptimer)*0.3,Rnd(0,15)
  296.         Oval pupx-10,pupy-10,15,15,1
  297.         Text pupx,pupy,puptext
  298.         poweruptimer=poweruptimer-1
  299.         If p1\x+5>pupx-(15/2) And p1\x-5<pupx+(15/2) And p1\y+5>pupy-(15/2) And p1\y-5<pupy+(15/2)
  300.             poweruptimer=0
  301.             PlaySound powerup_sound
  302.             If puptype=1 Then bulletdistance=4:bulletnumber=50:bulletspeed=4:pupcount=220+Rnd(100)
  303.             If puptype=2 Then bulletdistance=35:bulletnumber=4:bulletspeed=7:pupcount=50+Rnd(20)
  304.             If puptype=3 Then bulletdistance=10:bulletnumber=20:bulletspeed=5:pupcount=100+Rnd(100)
  305.             If puptype=4 Then p1\score=p1\score+1000:pupcount=0
  306.             If puptype=5 Then p1\shield=700:p1\autoshield=1000:pupcount=0
  307.             If puptype=6 Then p1\life=130:pupcount=0
  308.         EndIf        
  309.     EndIf
  310.     
  311.     If enemyships=0 And asters=0 And clearlevelcounter<=0 And level>0 Then clearlevelcounter=430:PlaySound click_sound
  312.     
  313.     If alienswelcome>0
  314.         ;unexpected guests!
  315.         If alienswelcomecounter>0
  316.             alienswelcomecounter=alienswelcomecounter-1
  317.         Else
  318.             e.enemy=New enemy
  319.             e\x=Rnd(width)
  320.             If Rnd(0,2)<1 Then e\y=-200 Else e\y=height+200
  321.             e\xvel=Rnd(4)-2
  322.             e\yvel=0
  323.             e\targcount=0
  324.             e\shooter=1
  325.             e\agression=999-(level*1.3)
  326.             e\aim=3
  327.             e\life=30+Rnd(50)
  328.             alienswelcome=Int(Rnd(0,1.9))
  329.             alienswelcomecounter=4000+Rnd(10000)
  330.         EndIf
  331.     EndIf
  332.     
  333.     ;SetFont smallfont
  334.     If clearlevelcounter>0
  335.     clearlevelcounter=clearlevelcounter-1
  336.         If bulletsfire>0 Then
  337.             percent=(bulletshit*100)/bulletsfire
  338.         Else
  339.             percent=0
  340.         EndIf
  341.         Color 0,10,70
  342.         ;SetFont hugefont
  343.         Text (width/2)-70,height/2-50,"level "+(level+1)
  344.         ;SetFont smallfont
  345.         Color 200,200,255
  346.         Text (width/2)-50,(height/2)-40,"level "+level+" cleared"
  347.         Text (width/2)-50,height/2,"bullets fired "+bulletsfire
  348.         Text (width/2)-50,(height/2)+15,"hits "+bulletshit
  349.         Text (width/2)-50,height/2+30,"hit percentage "+percent+"%"
  350.         If percent>75
  351.             If percent>99
  352.                 Text (width/2)-50,height/2+60,"perfect shooting! 3000 bonus"
  353.             Else    
  354.                 Text (width/2)-50,height/2+60,"excellent shooting! 600 bonus"    
  355.             EndIf
  356.         EndIf
  357.     EndIf
  358.     If clearlevelcounter=0 Then clearlevelcounter=-1:levelcleared()
  359.     
  360.     Color 0,10,70
  361.     ;SetFont hugefont
  362.     Text width-150,20,level
  363.     ;SetFont smallfont
  364.     Color 0,50,190
  365.     For t=1 To p1\lives
  366.         ;draw lives
  367.         Oval (width-170)+(t*20),32,10,10
  368.     Next    
  369.     If p1\score>=targetscorefornextlife Then
  370.         ;extra life earned
  371.         targetscorefornextlife=targetscorefornextlife+10000
  372.         PlaySound powerup_sound
  373.         p1\lives=p1\lives+1
  374.     EndIf
  375.  
  376.     Color 200,200,255
  377.     Nowtimer=MilliSecs()-Lasttimer
  378.     If nowtimer<9
  379.         Repeat:Until MilliSecs()-Lasttimer>=9
  380.     Else
  381. ;        Text width/2-10,20,"- low fps -"
  382.     EndIf
  383.     If debug=2
  384.         ;debug stuff
  385.         Text 0,0,p1\life
  386.         Text 0,20,puptype
  387.         Text 0,50,alienswelcomecounter+","+alienswelcome
  388.         Text 0,40,MilliSecs()-Lasttimer
  389.         Text 0,60,p1\an
  390.     EndIf
  391.     Lasttimer=MilliSecs()
  392.     Text width-150,0,"score:"+p1\score
  393.     If p1\score>hiscore Then hiscore=p1\score
  394.     Text width-150,15,"hiscore:"+hiscore
  395.  
  396.     ;VWait
  397.     Flip                                    ; Flip the buffers, to double buffer.
  398. Wend
  399. End    
  400.  
  401.  
  402. ;---------------------------------------------------------
  403.  
  404. ; Functions:
  405. Function UpdateShip()
  406.     For p.playership=Each playership                    ; Visit all entries in the list with this loop.
  407.  
  408.         p\anvel=p\anvel*0.91
  409.         p\an=p\an+p\anvel
  410.         If p\an>360 Then p\an=p\an-360
  411.         If p\an<0 Then p\an=p\an+360
  412.         
  413.         p\xvel=p\xvel+(p\speed*Cos(p\an))
  414.         p\yvel=p\yvel+(p\speed*Sin(p\an))
  415.         p\xvel=p\xvel*0.995    
  416.         p\yvel=p\yvel*0.995    
  417.         p\Lastx=p\x
  418.         p\Lasty=p\y
  419.         p\x=p\x+p\xvel : p\y=p\y+p\yvel
  420.         p\speed=p\speed*0.95
  421.     
  422.         If gameovercounter<=0 Then 
  423.             If p\x<-10 Then p\x=width+10
  424.             If p\x>width+10 Then p\x=-10
  425.             If p\y<-10 Then p\y=height+10
  426.             If p\y>height+10 Then p\y=-10
  427.         EndIf
  428.             
  429.         ; Draw Ship
  430.         If p\shieldflag>0 Then
  431.             Color 0,10,Rnd(100)+70
  432.             Oval p\x-(28/2),p\y-(28/2),28,28,1
  433.             Color 0,10,Rnd(100)+20
  434.             Oval p\x-(20/2),p\y-(20/2),20,20,1
  435.             ResumeChannel chnbuzz
  436.             p\xvel=p\xvel*0.98
  437.             p\yvel=p\yvel*0.98
  438.         Else
  439.             PauseChannel chnbuzz
  440.         EndIf
  441.         
  442.         tempg=160:tempr=160
  443.         If pupcount>0 Then tempg=255
  444.         If p1\life<20 Then tempr=255
  445.         Color tempr,tempg,160
  446.         headx=p\x+(Cos(p\an)*8)
  447.         heady=p\y+(Sin(p\an)*8)
  448.         Leftx=p\x+(Cos(p\an-140)*8)
  449.         Lefty=p\y+(Sin(p\an-140)*8)
  450.         Rightx=p\x+(Cos(p\an+140)*8)
  451.         Righty=p\y+(Sin(p\an+140)*8)
  452.         Line headx,heady,Rightx,Righty
  453.         Line headx,heady,Leftx,Lefty
  454.         Line Rightx,Righty,Leftx,Lefty    
  455.             
  456.         If p\life<0 Then 
  457.             ;life lost!
  458.             PlaySound exp_sound
  459.             makeexplosion(p\x,p\y,120,300)
  460.             p\x=Rnd(width-200)+100
  461.             p\y=Rnd(height-200)+100
  462.             p\xvel=0
  463.             p\yvel=0
  464.             p\life=100
  465.             p\shield=700
  466.             p\lives=p\lives-1
  467.             pupcount=0
  468.             bulletdistance=20 ;distance between the bullets
  469.             bulletnumber=10    ;number of bullets allowed on screen
  470.             bulletspeed=3
  471.             p\autoshield=300
  472.             If p\lives<=0 Then
  473.                 ;game over
  474.                 gameovercounter=1000
  475.                 p\x=-1000
  476.                 p\y=-1000
  477.             EndIf
  478.         EndIf    
  479.     Next
  480. End Function
  481.  
  482. Function UpdateAsteroid(fla)
  483.     ;do the asteroids
  484.     count=0
  485.     For p.asteroid=Each asteroid
  486.  
  487.         p\x=p\x+p\xvel : p\y=p\y+p\yvel
  488.         ;off screen maybe?
  489.         If p\x<(p\size/2)*-1 Then p\x=width+(p\size/2)
  490.         If p\x>width+(p\size/2) Then p\x=(p\size/2)*-1
  491.         If p\y<(p\size/2)*-1 Then p\y=height+(p\size/2)
  492.         If p\y>height+(p\size/2) Then p\y=(p\size/2)*-1
  493.         
  494.         If fla=0
  495.             For f.playership=Each playership
  496.             ;check for collision with player ship
  497.             If f\x+5>p\x-(p\size/2) And f\x-5<p\x+(p\size/2) And f\y+5>p\y-(p\size/2) And f\y-5<p\y+(p\size/2)
  498.             ;If RectsOverlap(f\x,f\y,10,10,p\x,p\y,p\size,p\size)
  499.                 If f\shieldflag<1
  500.                     f\life=f\life-p\size/2
  501.                     makeexplosion(f\x,f\y,60,20)
  502.                     SoundPan smexp_sound,(((f\x)-(width/2))/(width/2))*audioseperation
  503.                     PlaySound smexp_sound
  504.                 Else
  505.                     makeexplosion(f\x,f\y,30,10)
  506.                     SoundPan lowsmexp_sound,(((f\x)-(width/2))/(width/2))*audioseperation
  507.                     PlaySound lowsmexp_sound
  508.                 EndIf
  509.                 oldxvel#=f\xvel
  510.                 oldyvel#=f\yvel
  511.                 f\xvel=f\xvel+(p\xvel)/1
  512.                 f\yvel=f\yvel+(p\yvel)/1
  513.                 p\xvel=p\xvel+(oldxvel/20)
  514.                 p\yvel=p\yvel+(oldyvel/20)                
  515.             EndIf
  516.             Next
  517.         EndIf    
  518.         ; draw asteroid    
  519.         Color p\r,p\g,p\b
  520.         Oval p\x-(p\size/2),p\y-(p\size/2),p\size,p\size,1
  521.         ;Oval p\x,p\y,p\size,p\size,1
  522.         count=count+1
  523.     Next
  524.     Return count
  525. End Function
  526.  
  527. Function UpdateEnemy()
  528.     ;do the enemies
  529.     count=0
  530.     For p.enemy=Each enemy
  531.  
  532.         p\x=p\x+p\xvel : p\y=p\y+p\yvel
  533.         If p\shooter=1
  534.             Color 150,70,150
  535.             sp#=0.013
  536.             If p\x>p\targx Then p\xvel=p\xvel-sp
  537.             If p\y>p\targy Then p\yvel=p\yvel-sp
  538.             If p\x<p\targx Then p\xvel=p\xvel+sp
  539.             If p\y<p\targy Then p\yvel=p\yvel+sp
  540.             p\xvel=p\xvel*0.994
  541.             p\yvel=p\yvel*0.994
  542.             p\targcount=p\targcount-1
  543.             If p\targcount<=0 Then p\targcount=200+Rnd(700):p\targx=Rnd(width-100)+50:p\targy=Rnd(height-100)+50
  544.             If Rnd(200,1000)>p\agression Then enemyfirebullet(450,p\x,p\y,p\xvel,p\yvel,1.8,p\aim)
  545.         Else
  546.             Color 250,100,10
  547.             If p\x<0 Or p\x>((width)-5) Then p\xvel=-p\xvel
  548.             If p\y<0 Or p\y>((height)-5) Then p\yvel=-p\yvel
  549.             If Rnd(1000)>p\agression Then enemyfirebullet(450,p\x,p\y,p\xvel,p\yvel,enemybulletspeed,p\aim)
  550.         EndIf
  551.         For f.playership=Each playership
  552.             ;check for collision with player ship
  553.             If f\x>p\x-15 And f\x<p\x+15 And f\y>p\y-10 And f\y<p\y+10
  554.                 If f\shieldflag<1
  555.                     f\life=f\life-10
  556.                     makeexplosion(f\x,f\y,60,20)
  557.                     SoundPan smexp_sound,(((f\x)-(width/2))/(width/2))*audioseperation
  558.                     PlaySound smexp_sound
  559.                 Else
  560.                     makeexplosion(f\x,f\y,30,10)
  561.                     SoundPan lowsmexp_sound,(((f\x)-(width/2))/(width/2))*audioseperation
  562.                     PlaySound lowsmexp_sound
  563.                 EndIf
  564.                 f\xvel=(f\xvel+p\xvel)/1
  565.                 f\yvel=(f\yvel+p\yvel)/1                
  566.             EndIf
  567.         Next        
  568.  
  569.         Oval p\x,p\y,15,10,1
  570.         
  571.         count=count+1
  572.     Next
  573.     Return count
  574. End Function
  575.  
  576. Function updatebullets()
  577.     For f.bullet=Each bullet
  578.         f\x=f\x+f\xvel
  579.         f\y=f\y+f\yvel
  580.             If f\x<-10 Then f\x=width+10
  581.             If f\x>width+10 Then f\x=-10
  582.             If f\y<-10 Then f\y=height+10
  583.             If f\y>height+10 Then f\y=-10
  584.         f\life=f\life-1
  585.         Color 255,255,255
  586.         Plot f\x,f\y
  587.         If f\fromwho=1
  588.         ;if coming from player...
  589.         Color 255,255,255
  590.         For p.enemy=Each enemy
  591.             If f\x>p\x-10 And f\x<p\x+10 And f\y>p\y-10 And f\y<p\y+10
  592.                 bulletshit=bulletshit+1
  593.                 makeexplosion(f\x,f\y,70,20)
  594.                 f\life=-1
  595.                 p\life=p\life-Rnd(50)
  596.                 p\xvel=p\xvel+f\xvel/2
  597.                 p\yvel=p\yvel+f\yvel/2
  598.                 p1\score=p1\score+25
  599.                 If p\life<=0 Then
  600.                     makeexplosion(f\x,f\y,70,40)
  601.                     p1\score=p1\score+50
  602.                     SoundPan exp_sound,(((p\x)-(width/2))/(width/2))*audioseperation
  603.                     PlaySound exp_sound
  604.                     Delete p
  605.                 Else
  606.                     SoundPan smexp_sound,(((p\x)-(width/2))/(width/2))*audioseperation
  607.                     PlaySound smexp_sound
  608.                 EndIf
  609.             EndIf
  610.         Next
  611.         For h.asteroid=Each asteroid
  612.             If f\x>h\x-(h\size/2) And f\x<h\x+(h\size/2) And f\y>h\y-(h\size/2) And f\y<h\y+(h\size/2)
  613.                 makeexplosion(f\x,f\y,70,20)
  614.                 bulletshit=bulletshit+1
  615.                 f\life=-1
  616.                 h\xvel=h\xvel+f\xvel/15
  617.                 h\yvel=h\yvel+f\yvel/15
  618.                 h\size=h\size-20
  619.                 SoundPan smexp_sound,(((h\x)-(width/2))/(width/2))*audioseperation
  620.                 PlaySound smexp_sound
  621.                 If h\size<10 Then
  622.                     Delete h
  623.                     p1\score=p1\score+20
  624.                 Else
  625.                     p1\score=p1\score+5
  626.                     i.asteroid=New asteroid
  627.                     i\x=h\x:i\y=h\y
  628.                     i\size=h\size+Rnd(6)-3
  629.                     i\r=h\r:i\g=h\r:i\b=h\b
  630.                     i\an=h\an+(Rnd(6)-3)*6
  631.                     If i\an>360 Then i\an=i\an-360
  632.                     If i\an<0 Then i\an=i\an+360
  633.                     i\speed=h\speed
  634.                     i\xvel=(i\speed*Cos(i\an))
  635.                     i\yvel=(i\speed*Sin(i\an))
  636.                 EndIf
  637.             EndIf
  638.         Next
  639.         Else
  640.         ;from enemy
  641.         Color 0,255,255
  642.         For j.playership=Each playership
  643.             If f\x>j\x-10 And f\x<j\x+10 And f\y>j\y-10 And f\y<j\y+10
  644.                 If j\shieldflag<1
  645.                     j\life=j\life-(30+Rnd(10))
  646.                     makeexplosion(f\x,f\y,70,40)
  647.                     SoundPan smexp_sound,(((j\x)-(width/2))/(width/2))*audioseperation
  648.                     PlaySound smexp_sound
  649.                 Else
  650.                     makeexplosion(f\x,f\y,30,10)
  651.                     SoundPan lowsmexp_sound,(((j\x)-(width/2))/(width/2))*audioseperation
  652.                     PlaySound lowsmexp_sound
  653.                 EndIf
  654.                 makeexplosion(f\x,f\y,70,40)
  655.                 f\life=-1
  656.  
  657.             EndIf
  658.         Next            
  659.         EndIf
  660.         Plot f\x,f\y
  661.         If f\life<0 Then
  662.             Delete f
  663.             bulletsfired=bulletsfired-1
  664.         EndIf
  665.     Next
  666. End Function
  667.  
  668. Function firebullet(life,speed#)
  669. ;fire a bullet if you can
  670. If bulletsfired<bulletnumber
  671.     bulletsfired=bulletsfired+1
  672.     SoundPan fire_sound,(((p1\x)-(width/2))/(width/2))*audioseperation
  673.     PlaySound fire_sound
  674.     f.bullet= New bullet
  675.     bulletsfire=bulletsfire+1
  676.     If pupcount>0 Then pupcount=pupcount-1
  677.     f\x=p1\x
  678.     f\y=p1\y
  679.     f\xvel=p1\xvel+(speed*Cos(p1\an))
  680.     f\yvel=p1\yvel+(speed*Sin(p1\an))
  681.     f\life=life
  682.     f\fromwho=1
  683. EndIf
  684. End Function
  685.  
  686. Function enemyfirebullet(life,x#,y#,xvel#,yvel#,bulspeed#,aim#)
  687.     angle#=ATan2(p1\x-x,p1\y-y)
  688.     ang#=(90-angle#)+(Rnd(aim)-(aim/2))
  689.     f.bullet= New bullet
  690.     SoundPan fire_sound,(((x)-(width/2))/(width/2))*audioseperation
  691.     PlaySound fire_sound
  692.     f\x=x
  693.     f\y=y
  694.     f\xvel=(Cos(ang)*bulspeed)
  695.     f\yvel=(Sin(ang)*bulspeed)
  696.     f\life=life
  697.     f\fromwho=2
  698. End Function
  699.  
  700. Function makeexplosion(xe,ye,Inten,part)
  701.     For k=1 To part
  702.         f.Frag=New Frag
  703.         f\x=xe
  704.         an=Rnd(0,359)
  705.         f\y=ye
  706.         f\xs=Cos( an ) * Rnd( Inten-50,Inten )/10
  707.         f\ys=Sin( an ) * Rnd( Inten-50,Inten )/10
  708.         f\r=255:f\g=255:f\b=255
  709.     Next
  710. End Function
  711.  
  712. Function UpdateExplosion()
  713.     ;update the explosion particles
  714.     For f.Frag=Each Frag
  715.         f\xs=f\xs*0.99
  716.         f\ys=f\ys*0.99
  717.         f\x=f\x+f\xs
  718.         f\y=f\y+f\ys
  719.         f\ys=f\ys+0.06
  720.         Color f\r,f\g,f\b
  721.         Plot f\x,f\y
  722.         If f\x<0 Or f\x>=width Or f\y>=height
  723.             Delete f
  724.         Else If f\b>10
  725.             f\b=f\b-7
  726.         Else If f\g>10
  727.             f\g=f\g-4
  728.         Else If f\r>0
  729.             f\r=f\r-2
  730.             If f\r<=0 Then Delete f
  731.         EndIf
  732.     Next
  733. End Function
  734.  
  735. Function levelcleared()
  736.         ; the level is done, so make a new one!
  737.         If level=0
  738.             For en=1 To 3
  739.             g.asteroid=New asteroid
  740.             g\x=Rnd(width)
  741.             g\y=Int(Rnd(0,1))*height
  742.             g\an=Rnd(359)
  743.             g\speed=Rnd(200)/100
  744.             g\xvel=g\xvel+(g\speed*Cos(g\an))
  745.             g\yvel=g\yvel+(g\speed*Sin(g\an))
  746.             ;g\xvel=(Rnd(400)-200)/100
  747.             ;g\yvel=(Rnd(400)-200)/100
  748.             g\size=Rnd(60,80)
  749.             g\r=Rnd(30,80)
  750.             g\g=Rnd(25,60)
  751.             g\b=0
  752.             Next            
  753.             level=1
  754.         Else
  755.             level=level+1
  756.             pupprobability=5000-(level*150):If pupprobability<100 Then pupprobability=100    ;more frequent powerups as time progresses    
  757.         If bulletsfire>0 Then
  758.             percent=(bulletshit*100)/bulletsfire
  759.         Else
  760.             percent=0
  761.         EndIf
  762.         ;add bonus
  763.         If percent>75 Then p1\score=p1\score+600
  764.         If percent>99 Then p1\score=p1\score+3000
  765.     
  766.     ; make random level    
  767.     Selection=Int(Rnd(1,8))
  768.         
  769.     If Selection<=4 Then 
  770.         ;normal level
  771.         numofenemi=1+Int(Rnd(0,level/2))
  772.         For en=1 To numofenemi
  773.         e.enemy=New enemy
  774.         e\x=Rnd(width)
  775.         e\y=Rnd(height)
  776.         e\xvel=Rnd(4)-2
  777.         e\yvel=Rnd(4)-2
  778.         e\agression=999-(level*(Int(Rnd(0,1.5))))
  779.         e\aim=3
  780.         e\life=30+Rnd(50)
  781.         enemybulletspeed=1.2
  782.         If level>=5 Then If Rnd(0,5)>=4 Then e\shooter=1:e\agression=999-(level*0.8)+(numofenemi/2)
  783.         If level>=12 Then If Rnd(0,2)>=1 Then e\shooter=1:e\agression=999-(level*0.8)+(numofenemi/2)
  784.         Next
  785.     
  786.         For en=1 To 1+Int(Rnd(level/2,level/1.3))
  787.         g.asteroid=New asteroid
  788.         g\x=Rnd(width)
  789.         g\y=Int(Rnd(0,1))*height
  790.         g\an=Rnd(359)
  791.         g\speed=Rnd(150)/100
  792.         g\xvel=g\xvel+(g\speed*Cos(g\an))
  793.         g\yvel=g\yvel+(g\speed*Sin(g\an))
  794.         g\size=Rnd(60,80)
  795.         g\r=Rnd(30,80)
  796.         g\g=Rnd(25,60)
  797.         g\b=0
  798.         life=100
  799.         Next
  800.     
  801.     EndIf
  802.     If Selection>=7 Then
  803.         ;only enemies level
  804.         numofenemi=2+Int(Rnd(level/2.5))
  805.         For en=1 To numofenemi
  806.         e.enemy=New enemy
  807.         e\x=Rnd(width)
  808.         e\y=Rnd(height)
  809.         e\xvel=Rnd(4)-2
  810.         e\yvel=Rnd(4)-2
  811.         e\agression=999-(level*(Int(Rnd(0,1.5))))
  812.         e\aim=3
  813.         e\life=50+Rnd(50)
  814.         enemybulletspeed=1.2+(level/25)
  815.         If level>=5 Then If Rnd(0,5)>=4 Then e\shooter=1:e\agression=1000-(level*1)+(numofenemi/2)
  816.         If level>=12 Then If Rnd(0,2)>=1 Then e\shooter=1:e\agression=1000-(level*1)+(numofenemi/2)    
  817.         Next
  818.     EndIf
  819.     
  820.     If Selection=5 Then    
  821.         ;only asteroids level
  822.         For en=1 To 1+Int(Rnd(level/2,level/1.5))
  823.         g.asteroid=New asteroid
  824.         g\x=Rnd(width)
  825.         g\y=Int(Rnd(0,1))*height
  826.         g\an=Rnd(359)
  827.         g\speed=Rnd(200)/100
  828.         g\xvel=g\xvel+(g\speed*Cos(g\an))
  829.         g\yvel=g\yvel+(g\speed*Sin(g\an))
  830.         g\size=Rnd(60,80)
  831.         g\r=Rnd(30,80)
  832.         g\g=Rnd(25,60)
  833.         g\b=0
  834.         life=100
  835.         Next
  836.     EndIf
  837.  
  838.     If Selection=6 Then    
  839.         ;huge asteroids level
  840.         For en=1 To Int(Rnd(0,2))+1
  841.         g.asteroid=New asteroid
  842.         g\x=Rnd(width)
  843.         g\y=Int(Rnd(0,1))*height
  844.         g\an=Rnd(359)
  845.         g\speed=Rnd(120)/100
  846.         g\xvel=g\xvel+(g\speed*Cos(g\an))
  847.         g\yvel=g\yvel+(g\speed*Sin(g\an))
  848.         g\size=Rnd(80,150)
  849.         g\r=Rnd(30,80)
  850.         g\g=Rnd(25,60)
  851.         g\b=0
  852.         life=100
  853.         Next
  854.     EndIf
  855.     
  856.     p1\life=100+(level*3)
  857.     bulletsfire=0:bulletshit=0
  858.     p1\autoshield=300
  859.     p1\shieldflag=0
  860.     p1\shield=600
  861.     If level>=5 Then alienswelcome=Int(Rnd(0,3))
  862.     alienswelcomecounter=1000+Rnd(9000)
  863.     
  864.     EndIf
  865. End Function
  866.  
  867. Function initgame()
  868. ; called at the beginning of each game
  869.  
  870. p1\x=400
  871. p1\y=300
  872. p1\xvel=0
  873. p1\yvel=0
  874. p1\an=0
  875. p1\life=100
  876. p1\lives=3
  877. p1\shield=700
  878. p1\autoshield=300
  879. p1\shieldflag=0
  880. p1\score=0
  881. pupcount=0
  882. bulletdistance=20 ;distance between the bullets
  883. bulletnumber=10    ;number of bullets allowed on screen
  884. bulletspeed=3
  885. enemybulletspeed=1.2
  886.  
  887. clearlevelcounter=-1
  888. level=0
  889. pupprobability=5000
  890. targetscorefornextlife=10000
  891.  
  892. ;clear all!
  893.     For p.asteroid=Each asteroid
  894.     Delete p
  895.     Next
  896.     
  897.     For g.enemy=Each enemy
  898.     Delete g
  899.     Next
  900.     
  901.     For h.bullet=Each bullet
  902.     Delete h
  903.     Next
  904.  
  905. End Function
  906.  
  907.  
  908. ;--------------------------------------- TITLE -----------------
  909. Function titlescreen()
  910. PauseChannel chnbuzz
  911.  
  912. If Not ChannelPlaying(music)
  913.     music=PlayMusic( "kamelpiano.mid" )
  914. End If
  915.  
  916.  
  917. If OpenFile("aristoidsprefs")
  918.     loadhighscores("aristoidsprefs"):;CloseFile("aristoidsprefs")
  919. Else
  920.     blankhighscores("aristoidsprefs")
  921.     loadhighscores("aristoidsprefs")
  922. EndIf
  923. hiscore=hiscores(1)
  924.  
  925.         ; get some asteroids in
  926.         For en=1 To 5+Int(Rnd(15))
  927.         g.asteroid=New asteroid
  928.         g\x=Rnd(width)
  929.         g\y=Int(Rnd(0,1))*height
  930.         g\an=Rnd(359)
  931.         g\speed=(Rnd(200)/100)+0.05
  932.         g\xvel=g\xvel+(g\speed*Cos(g\an))
  933.         g\yvel=g\yvel+(g\speed*Sin(g\an))
  934.         g\size=Rnd(10,80)
  935.         g\r=Rnd(30,80)
  936.         g\g=Rnd(25,60)
  937.         g\b=0
  938.         life=100
  939.         Next
  940.     
  941. Repeat
  942. Cls
  943.  
  944.  
  945.  
  946.  
  947. Text 30,30,"aristoids"
  948. Text 30,45,"by aristides mytaras"
  949. Text 30,60,"aristid@freemail.gr"
  950.  
  951.  
  952. If KeyDown(23)=0
  953.  
  954. If KeyDown(46) And controlcountdown<=0
  955.     controltype=controltype+1:controlcountdown=30
  956.     If controltype>2 Then controltype=0
  957. EndIf
  958. If controlcountdown>0 Then controlcountdown=controlcountdown-1
  959.  
  960. Color 0,10,70
  961. ;SetFont hugefont
  962. Text 80,100,"score:"+hiscore
  963. Text width-350,height-110,"i for info"
  964.  
  965. ;Text 50,305,"high scores"
  966.  
  967. Color 200,200,255
  968.  
  969. Text 30,90,"last score:"+p1\score
  970. Text 30,105,"high score:"+hiscore
  971.  
  972. ;SetFont smallfont
  973. For t=1 To 10
  974. If t<10 Then
  975.     Text 100,(t*15)+160,t+". "+hinames(t)
  976. Else
  977.     Text 91,(t*15)+160,t+". "+hinames(t)
  978. EndIf
  979. Text 250,(t*15)+160,hiscores(t)
  980. Text 340,(t*15)+160,levelreached(t)
  981. Text 420,(t*15)+160,hidates(t)
  982. If control(t)=0 Then tempstr$="ast"
  983. If control(t)=1 Then tempstr$="beg"
  984. If control(t)=2 Then tempstr$="mix"
  985. Text 380,(t*15)+160,tempstr$
  986. Next
  987.  
  988. Color 0,10,70
  989. ;SetFont hugefont
  990. If controltype=0 Then tempstr$="asteroids"
  991. If controltype=1 Then tempstr$="beginner"
  992. If controltype=2 Then tempstr$="mixed"
  993. Text 30,height-80,tempstr$
  994.  
  995. Color 200,200,255
  996. ;SetFont smallfont
  997. Text 30,height-70,"control type:"+tempstr$
  998.  
  999. Text width-300,height-80,"switch resolutions with f1,f2,f3"
  1000. Text width-300,height-65,"press i for more info"
  1001. Else
  1002. Color 0,10,70
  1003. ;SetFont hugefont
  1004. Text 190,310,width+"x"+height
  1005. Color 200,200,255
  1006. SetFont smallfont
  1007. Text 30,120,"use left/right/</> to turn, up/z for thrust,"
  1008. Text 30,135,"down or shift for shield/brake, ctrl or space to fire"
  1009. Text 30,155,"or a joystick, or a hotrod - press c to select control type"
  1010. Text 30,175,"destroy everything to advance through the levels"
  1011. Text 30,195,"your shield and energy replenish at the end of each level"
  1012. Text 30,230,"achieve a 75% or better accuracy for bonus"
  1013. Text 30,245,"achieve a 100% accuracy for huge bonus"
  1014. Text 30,260,"extra life awarded every 10000 points"
  1015. Text 30,310,"f1 to switch to 640x480"
  1016. Text 30,325,"f2 to switch to 800x600"
  1017. Text 30,340,"f3 to switch to 1024x800"
  1018. Text 30,355,"resolution has impact on gameplay. normal at 1024x768 (default), frantic at 640x480"
  1019. Text 30,390,"music (c)1998 by aristides mytaras"
  1020. Text 30,height-65,"this version of aristoids is freeware as long as the code stays intact"
  1021. Text 30,height-50,"you ar not allowed to distribute a modified version of aristoids"
  1022. Text 30,height-35,"programmed in blitz basic on 18-19 sept 2000 in athens, greece"
  1023.  
  1024.  
  1025. EndIf
  1026.  
  1027. If KeyDown(1) Then End
  1028.  
  1029. If KeyDown(59)
  1030. Repeat
  1031. nono=0
  1032. For t=0 To 255
  1033. If KeyDown(t)<>0 Then nono=1
  1034. Next
  1035. Until nono=0
  1036. width=640:height=480:depth=16
  1037. Graphics width,height
  1038. SetBuffer BackBuffer():savehighscores("aristoidsprefs")
  1039. EndIf
  1040. If KeyDown(60)
  1041. Repeat
  1042. nono=0
  1043. For t=0 To 255
  1044. If KeyDown(t)<>0 Then nono=1
  1045. Next
  1046. Until nono=0
  1047. width=800:height=600:depth=16
  1048. Graphics width,height
  1049. SetBuffer BackBuffer():savehighscores("aristoidsprefs")
  1050. EndIf
  1051. If KeyDown(61)
  1052. Repeat
  1053. nono=0
  1054. For t=0 To 255
  1055. If KeyDown(t)<>0 Then nono=1
  1056. Next
  1057. Until nono=0
  1058. width=1024:height=768:depth=16
  1059. Graphics width,height
  1060. SetBuffer BackBuffer():savehighscores("aristoidsprefs")
  1061. EndIf
  1062.  
  1063. If Rnd(1000)>970 Then makeexplosion(Rnd(width),Rnd(height),Rnd(100)+50,Rnd(300)+80)
  1064.  
  1065. asters=UpdateAsteroid(1)
  1066. UpdateExplosion()
  1067.  
  1068.     Nowtimer=MilliSecs()-Lasttimer
  1069.     If nowtimer<9
  1070.         Repeat:Until MilliSecs()-Lasttimer>=9
  1071.     EndIf
  1072.     Lasttimer=MilliSecs()
  1073.  
  1074. Flip
  1075. Until KeyDown(57) Or KeyDown(29) Or (joystick<>0 And JoyDown(1))
  1076.  
  1077. Repeat
  1078. nono=0
  1079. For t=0 To 255
  1080. If KeyDown(t)<>0 Or (joystick<>0 And JoyDown(1)) Then nono=1
  1081. Next
  1082. Until nono=0
  1083.  
  1084.     For p.asteroid=Each asteroid
  1085.     Delete p
  1086.     Next
  1087.  
  1088. savehighscores("aristoidsprefs")
  1089. initgame()
  1090. levelcleared()
  1091.  
  1092. StopChannel Music 
  1093.  
  1094. End Function
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105. ;--------------highscore functions------------
  1106. ;----------------------------
  1107. Function savehighscores(name$)
  1108. ;name$=name$+".txt"
  1109. savegame=WriteFile(name)
  1110. WriteLine savegame,"aristoids save file"
  1111. WriteLine savegame,CurrentDate()+" - "+CurrentTime()
  1112. For t=1 To 11
  1113. WriteLine savegame,hiscores(t)
  1114. WriteLine savegame,hinames(t)
  1115. WriteLine savegame,hidates(t)
  1116. WriteLine savegame,levelreached(t)
  1117. WriteLine savegame,control(t)
  1118. Next
  1119. WriteLine savegame,width
  1120. WriteLine savegame,height
  1121. WriteLine savegame,controltype
  1122. CloseFile(savegame)
  1123. End Function
  1124.  
  1125. ;----------------------------
  1126. Function loadhighscores(name$)
  1127. ;name$=name$+".txt"
  1128. savegame=ReadFile(name)
  1129. For no=1 To 2:nouse$=ReadLine$(savegame):Next
  1130. ;While Not Eof(savegame)
  1131. ;    Print ReadLine$(savegame)
  1132. ;Wend
  1133. For t=1 To 11
  1134. hiscores(t)=ReadLine$(savegame):;Print "loader-"+t+hiscores(t)
  1135. hinames(t)=ReadLine$(savegame):;Print hinames$(t)
  1136. hidates(t)=ReadLine$(savegame)
  1137. levelreached(t)=ReadLine$(savegame)
  1138. control(t)=ReadLine$(savegame)
  1139. Next
  1140. width=ReadLine$(savegame)
  1141. height=ReadLine$(savegame)
  1142. controltype=ReadLine$(savegame)
  1143. If GraphicsHeight()<>height And GraphicsWidth()<>width Then Graphics width,height:SetBuffer BackBuffer()
  1144. CloseFile savegame
  1145. End Function
  1146.  
  1147. ;-----------------------------
  1148. Function blankhighscores(name$)
  1149. ;name$=name$+".txt"
  1150. savegame=WriteFile(name)
  1151. WriteLine savegame,"aristoids save file"
  1152. WriteLine savegame,CurrentDate()+" - "+CurrentTime()+" - default"
  1153. For t=1 To 11
  1154. WriteLine savegame,(11-t)*100
  1155. If Rnd(1,3)<2 Then WriteLine savegame,"aristides" Else WriteLine savegame,"vasso"
  1156. WriteLine savegame," "
  1157. WriteLine savegame,"0"
  1158. WriteLine savegame,0
  1159. Next
  1160. WriteLine savegame,width
  1161. WriteLine savegame,height
  1162. WriteLine savegame,controltype
  1163. CloseFile(savegame)
  1164. End Function
  1165.  
  1166. ;-----------------------------
  1167. Function sorthighscores(file$,name$,score,levelreach)
  1168. loadhighscores(file)
  1169.  
  1170. done=0
  1171. t=1
  1172. Repeat
  1173.     If hiscores(t)<score Then
  1174.         done=1
  1175.         For e=10 To t Step -1
  1176.             hiscores(e+1)=hiscores(e)
  1177.             hinames(e+1)=hinames(e)
  1178.             hidates(e+1)=hidates(e)
  1179.             levelreached(e+1)=levelreached(e)
  1180.             control(e+1)=control(e)
  1181.         Next
  1182.         hiscores(t)=score
  1183.         hinames(t)=name
  1184.         hidates(t)=CurrentDate()
  1185.         levelreached(t)=levelreach
  1186.         control(t)=controltype
  1187.     EndIf
  1188. t=t+1
  1189. Until t=10 Or done=1
  1190.  
  1191. End Function
  1192.  
  1193. ;-------------------------------
  1194. Function checkhighscore(thisfile$,sco)
  1195. loadhighscores(thisfile$)
  1196. highscoreplace=20
  1197. For t=10 To 1 Step -1
  1198.     If hiscores(t)<=sco Then highscoreplace=t
  1199.     ;Print t+" "+hiscores(t)
  1200. Next
  1201. Return highscoreplace
  1202. End Function
  1203.  
  1204. ;---------------------------------
  1205. Function entername(startname$,score)
  1206. yourname$=startname
  1207. PlaySound buzz_sound
  1208.  
  1209. flush=10
  1210. Repeat
  1211. flush=GetKey()
  1212. Print flush
  1213. Until flush=0
  1214.  
  1215. While Not (KeyDown(1) Or KeyDown(28))
  1216. Cls
  1217.  
  1218. a=GetKey()
  1219. If a>=32 And a<=122 And Len(yourname)<15
  1220.     yourname=yourname+Chr$(a)
  1221. EndIf
  1222. If (KeyHit(14) Or KeyHit(211)) And Len(yourname)>0 Then yourname=Left$(yourname,Len(yourname)-1)
  1223.  
  1224. Color 0,10,70
  1225. ;SetFont hugefont
  1226. Text 60,115,score
  1227. Text 60,200,yourname
  1228.  
  1229.  
  1230. Color 200,200,255
  1231.  
  1232. Text 40,100,"you have achieved a high score"
  1233. Text 40,115,"please enter your name:"
  1234. Text 60,170,yourname
  1235.  
  1236. If Rnd(1000)>970 Then makeexplosion(Rnd(width),Rnd(height),Rnd(100)+50,Rnd(300)+80)
  1237. UpdateExplosion()
  1238.     Nowtimer=MilliSecs()-Lasttimer
  1239.     If nowtimer<9
  1240.         Repeat:Until MilliSecs()-Lasttimer>=9
  1241.     EndIf
  1242.     Lasttimer=MilliSecs()
  1243.  
  1244. Flip
  1245. Wend
  1246. ;Return yourname ;doesnt work!
  1247. End Function